<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    public function __construct(){
    	
    }

    /**
	 * 获取当前控制器名
	 *
	 * @return string
	 */
	protected function getCurrentControllerName()
	{
	    return $this->getCurrentAction()['controller'];
	}

	/**
	 * 获取当前方法名
	 *
	 * @return string
	 */
	protected function getCurrentMethodName()
	{
	    return $this->getCurrentAction()['method'];
	}

	/**
	 * 获取当前控制器与方法
	 *
	 * @return array
	 */
	protected function getCurrentAction()
	{
	    $action = \Route::current()->getActionName();
	    list($class, $method) = explode('@', $action);
	    $class = explode("\\",$class);
	    $count = count($class);
	    $class = $class[$count-1];
	    return ['controller' => $class, 'method' => $method];
	}
}
